package com.yangye.pisystem.service.impl;

import com.yangye.picommon.core.service.impl.BaseServiceImpl;
import com.yangye.picommon.utils.TreeUtil;
import com.yangye.pisystem.dao.SysRouterMapper;
import com.yangye.pisystem.domain.SysRouter;
import com.yangye.pisystem.dto.SysRouterDTO;
import com.yangye.pisystem.service.SysRouterService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yangye
 * @date 2019/8/6
 */
@Service
public class SysRouterServiceImpl extends BaseServiceImpl<SysRouterMapper, SysRouter> implements SysRouterService {
	@Override
	public List<SysRouterDTO> listTree() {
		List<SysRouter> sysRouters = dao.selectAll();
		List<SysRouterDTO> list = new ArrayList<>();
		for (SysRouter sysRouter : sysRouters) {
			SysRouterDTO sysRouterDTO = new SysRouterDTO();
			BeanUtils.copyProperties(sysRouter, sysRouterDTO);
			list.add(sysRouterDTO);
		}
		return TreeUtil.parseTree(list);
	}
}
